<?php
/**
 * Smarty plugin
 * @package Smarty
 * @subpackage plugins
 */


/**
 * Smarty cc modifier plugin
 *
 * Type:     modifier<br>
 * Name:     cc<br>
 * Purpose:  Substr a string to a certain length if necessary,
 *           optionally splitting in the middle of a word, and
 *           appending the $etc string or inserting $etc into the middle.
 * @link http://smarty.php.net/manual/en/language.modifier.cc.php
 *          cc (Smarty online manual)
 * @author   Monte Ohrt <monte at ohrt dot com>
 * @param string
 * @param integer
 * @param string
 * @param boolean
 * @param boolean
 * @return string
 */
function smarty_modifier_cc($string, $type = '')
{
	include_once(CONFIG_PATH . CONFIG_DIR_FUNCTIONS . 'cc.function.php');
	
	if( $type == 'encrypt' ) {
		
	} elseif( $type == 'decrypt' ) {
		$value = func_cc_decrypt($string);
		
		return $value;
	} elseif( $type == 'lastencrypt' ) {
		
	} elseif( $type == 'lastdecrypt' || $type == 'last' ) {
		$value = func_cc_decrypt($string);
		
		return substr($value, -4);
	} elseif( $type == 'lastdecrypt_x' || $type == 'last_x' || $type == 'lastx' ) {
		$value = func_cc_decrypt($string);
		
		return 'XXX-' . substr($value, -4);
	}
	
	return '';
}
//
?>